<template>
  <a-card :bordered="false">
    <div style="display: flex; justify-content: space-between">
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('订单表')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      </div>
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-form-item label="城市服务商" style="margin-right: 10px" v-has="'xhdjdataAnalysis:select'">
            <serveSelect @selectClick="selectClick" :value="queryParam.agencyCode"></serveSelect>
          </a-form-item>
          <a-form-item label="技师名称" style="margin-right: 10px">
            <a-input placeholder="请输入技师名称" v-model="queryParam.coachName" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <a-form-item label="开始时间" style="margin-right: 10px">
            <a-date-picker v-model="queryParam.startTime" @change="startChange" :valueFormat="'YYYY-MM-DD'" />
          </a-form-item>
          <a-form-item label="结束时间" style="margin-right: 10px">
            <a-date-picker
              v-model="queryParam.endTime"
              @change="endChange"
              :valueFormat="'YYYY-MM-DD'"
              :disabled-date="disabledDate"
            />
          </a-form-item>
          <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </span>
        </a-form>
      </div>
    </div>

    <!-- table区域-begin -->
    <!-- <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="j-table-force-nowrap"
      @change="handleTableChange"
    >
      <!-- 健康证 -->
      <template slot="workImg" slot-scope="text, record">
        <div class="anty-img-wrap">
          <a-avatar shape="square" :src="getAvatarView(record.workImg)" />
        </div>
      </template>
      <span slot="action" slot-scope="text, record">
        <a @click="handleEdit(record)">编辑</a>

        <a-divider type="vertical" />
        <a-dropdown>
          <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
          <a-menu slot="overlay">
            <a-menu-item>
              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
              </a-popconfirm>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
      </span>
    </a-table>

    <!-- table区域-end -->
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getFileAccessHttpUrl, getAction, httpAction } from '@/api/manage'
import serveSelect from '@/components/serveSelect.vue'

import moment from 'moment'
export default {
  name: 'xhdjFundLog',
  mixins: [JeecgListMixin],
  components: { serveSelect },
  data () {
    return {
      description: '技师分析',
      // 表头pickerOptions: {
      columns: [
        {
          title: '名称',
          align: 'center',
          dataIndex: 'coachName'
        },
        {
          title: '真实姓名',
          align: 'center',
          dataIndex: 'realName'
        },
        {
          title: '工作照',
          align: 'center',
          dataIndex: 'workImg',
          scopedSlots: { customRender: 'workImg' }
        },
        {
          title: '业绩等级',
          align: 'center',
          dataIndex: 'levelName'
        },
        {
          title: '下单人数',
          align: 'center',
          dataIndex: 'payOderUserCount'
        },
        {
          title: '回头客下单数',
          align: 'center',
          dataIndex: 'payOderUserReturnedCount'
        },
        {
          title: '回头客下单比例',
          align: 'center',
          dataIndex: 'payOderUserReturnedRate'
        },
        {
          title: '总的营业额(不含退款订单)',
          align: 'center',
          dataIndex: 'totalTurnoverNotRefundAmout'
          // dataIndex: 'totalTurnover',
        },
        // {
        //   title: '车费',
        //   align: 'center',
        //   dataIndex: 'totalUpFare',
        // },
        {
          title: '总的退款金额',
          align: 'center',
          dataIndex: 'totalRefundAmout'
        },
        {
          title: '总订单数量',
          align: 'center',
          dataIndex: 'totalOrderNum'
        },

        {
          title: '退款订单数量',
          align: 'center',
          dataIndex: 'totalOutOrderNum'
        },
        {
          title: '加钟订单数量',
          align: 'center',
          dataIndex: 'speedOrderNum'
        },

        {
          title: '总项目收入',
          align: 'center',
          dataIndex: 'totalCoachIncome'
        },
        {
          title: '总车费收入',
          align: 'center',
          dataIndex: 'totalFare'
        },
        {
          title: '总佣金收入',
          align: 'center',
          dataIndex: 'totalCommissionAmount'
        },
        {
          title: '提现项目费用',
          align: 'center',
          dataIndex: 'withdrawCoachIncome'
        },
        {
          title: '提现车费',
          align: 'center',
          dataIndex: 'withdrawFare'
        },
        {
          title: '提现佣金',
          align: 'center',
          dataIndex: 'withdrawCommissionAmount'
        },

        // {
        //   title: '项目余额',
        //   align: 'center',
        //   dataIndex: 'coachIncome',
        // },
        // {
        //   title: '车费余额',
        //   align: 'center',
        //   dataIndex: 'fare',
        // },
        {
          title: '加钟率',
          align: 'center',
          dataIndex: 'speedRate',
          customRender: (text, record) => {
            return (record.speedRate || 0) + '%'
          }
        },
        {
          title: '充值卡',
          align: 'center',
          dataIndex: 'topNum',
          customRender: (text, record) => {
            return record.topNum || 0
          }
        },

        {
          title: '在线时长',
          align: 'center',
          dataIndex: 'onlineTimeNum',
          customRender: (text, record) => {
            return (record.onlineTimeNum || 0) + '小时'
          }
        }
      ],
      url: {
        list: '/coach/xhdjCoachInfo/statisticsList'
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    getAvatarView: function (avatar) {
      return getFileAccessHttpUrl(avatar)
    },
    selectClick (value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    },
    disabledDate (time) {
      return new Date(time).getTime() < new Date(this.queryParam.startTime).getTime()
    },
    startChange (value) {
      if (value) {
        this.queryParam.startTime = value + ' 00:00:00'
      } else {
        this.queryParam.startTime = value
      }
    },
    endChange (value) {
      if (value) {
        this.queryParam.endTime = value + ' 23:59:59'
      } else {
        this.queryParam.endTime = value
      }
    }
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
.ant-row {
  display: flex;
  justify-content: flex-end;
}
.ant-col {
  display: flex;
  justify-content: flex-end;
}
.ant-form {
  display: flex;
}
</style>
